/*
- Copyright (C) 2002, 2003, 2004, 2005 Robert Lipe, robertlipe@usa.net
+ Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Robert Lipe, robertlipe@usa.net
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
unsigned int cet_converted:1; /* strings are converted to UTF8; interesting only for input */
} wp_flags;
+typedef struct url_link {
+ struct url_link *url_next;
+ char *url;
+ char *url_link_text;
+} url_link;
+
/*
* This is a waypoint, as stored in the GPSR. It tries to not
* cater to any specific model or protocol. Anything that needs to
* Few formats support this.
*/
char *notes;
+
+ /* This is a bit icky. Multiple waypoint support is an
+ * afterthought and I don't want to change our data structures.
+ * So we have the first in the waypoint itself and subsequent
+ * ones in a linked list.
+ */
+ struct url_link *url_next;
char *url;
char *url_link_text;
/* %%% local vars %%% */
-/* static char gdb_release[] = "$Revision: 1.48 $"; */
-static char gdb_release_date[] = "$Date: 2007/02/20 20:51:15 $";
+/* static char gdb_release[] = "$Revision: 1.49 $"; */
+static char gdb_release_date[] = "$Date: 2007/03/10 23:36:14 $";
static FILE *fin, *fout;
static char *fin_name, *fout_name;
gdb_is_valid((url_ct >= 0), prefix, "Number of urls (since v3)");
while (url_ct > 0) {
+ char v3xurl[GDB_URL_BUFFERLEN];
url_ct--;
- gdb_fread_str(xurl, sizeof(xurl)); /* URL list */
+ gdb_fread_str(v3xurl, sizeof(v3xurl)); /* URL list */
+ add_url(res, xstrdup(v3xurl), NULL);
+#if 0
if ((url == NULL) && (xurl[0] != '\0'))
url = xstrdup(xurl); /* keep only the first valid entry */
+#endif
}
if (url != NULL) {
strncpy(xurl, url, sizeof(xurl));
return (res == NULL) ? (char *) fname : ++res;
}
+
+void
+add_url(waypoint *wpt, char *link, char *url_link_text)
+{
+ /* Special case first one; it goes right into the waypoint. */
+ if ((wpt->url == NULL) && (wpt->url_link_text == NULL)) {
+ wpt->url = link;
+ wpt->url_link_text = url_link_text;
+ } else {
+ url_link *tail;
+ url_link *new_link = xcalloc(sizeof(url_link), 1);
+ new_link->url = link;
+ new_link->url_link_text = url_link_text;
+
+ /* Find current end of chain. */
+ for (tail = wpt->url_next;;tail = tail->url_next) {
+ if (tail == NULL) {
+ wpt->url_next = new_link;
+ break;
+ }
+ if (tail->url_next == NULL) {
+ tail->url_next = new_link;
+ break;
+ }
+ }
+ }
+}
/*
Perform various operations on waypoints.
- Copyright (C) 2002-2005 Robert Lipe, robertlipe@usa.net
+ Copyright (C) 2002-2007 Robert Lipe, robertlipe@usa.net
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
if (wpt->url_link_text) {
xfree(wpt->url_link_text);
}
+ if (wpt->url_next) {
+ url_link *url_next;
+
+ for (url_next = wpt->url_next; url_next; ) {
+
+ url_link *tonuke = url_next;
+ if (tonuke->url) {
+ xfree(tonuke->url);
+ }
+ if (tonuke->url_link_text) {
+ xfree(tonuke->url_link_text);
+ }
+ url_next = tonuke->url_next;
+ xfree(tonuke);
+ }
+ }
if (wpt->icon_descr && wpt->wpt_flags.icon_descr_is_dynamic) {
xfree((char *)(void *)wpt->icon_descr);
}